package com.ws.exer;

import java.util.Date;

/*
5.声明一个日期类型MyDate:有属性:年year,月month，日day。
创建2个日期对象，分别赋值为:你的出生日期，你对象的出生日期，并显示信息。

 */
public class MyDateTest {
    public static void main(String[] args) {
        MyDate[] myDates = new MyDate[2];

        for (int i = 0; i < myDates.length; i++) {
            myDates[i] = new MyDate();

            myDates[i].year = i==0? 2020: 2021;
            myDates[i].month = i==0? 8: 6;
            myDates[i].day = i==0? 28: 21;
        }

        MyDateTest test = new MyDateTest();
        test.print(myDates);
    }

    //遍历输出
    public void print(MyDate[] myDates) {
        for (MyDate myDate: myDates) {
            System.out.println(myDate.info());
        }
    }
}

class MyDate {
    int year;
    int month;
    int day;

    public String info() {
        return "year = " + year + ", month = " + month + ", day" + day;
    }
}